﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sx.Utils
{
    public static class RandomHelper
    {
        public static string GetNumber(int l) {
            return GetString(l,"0123456789");
        }

        public static string GetString(int l, string source) {
            if (source.IsNullOrEmpty()|| l ==0)
            {
                return "";
            }
            long tick = DateTime.Now.Ticks;
            Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
            StringBuilder sbResult = new StringBuilder(l);
            for (int i = 0; i < l; i++)
            {
                sbResult.Append(source[ran.Next(source.Length)]);
            }
            return sbResult.ToString();
        }
    }
}
